package unit10.preserveWholeObject;

/**
 * @author v_irlwang
 * @date 2021/5/11
 */
public class ExampleAfter {

    class Room {
        //某天的数据
        DayData dayData = new DayData();
        //计划对象
        HeatingPlan plan = new HeatingPlan();

        boolean withinPlan() {
            return plan.withinRang(dayData);
        }
    }

    //计算是否符合计划
    class HeatingPlan {
        TempRange range = new TempRange();

        boolean withinRang(DayData dayData) {
            return range.includes(dayData);
        }
    }

    //某一天的温度
    class DayData {
        private int low;
        private int high;

        public int getLow() {
            return low;
        }

        public int getHigh() {
            return high;
        }
    }

    //模板
    class TempRange {
        boolean includes(DayData dayData) {
            return dayData.getLow() >= low
                    && dayData.getHigh() <= high;
        }

        //温度标准范围
        private int low = 20;
        private int high = 26;
    }

}
